<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="2.0" 
  xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 
  xmlns:fo="http://www.w3.org/1999/XSL/Format" 
  xmlns:xs="http://www.w3.org/2001/XMLSchema" 
  xmlns:fn="http://www.w3.org/2005/xpath-functions">
  <xsl:template match="/contact">
    <html>
      <head>
        <title>
          <xsl:value-of select="@address"/>
        </title>
        <link rel="stylesheet" type="text/css" href="include/ndara.css" />
      </head>
      <body>
        <div class="mainBorder">
          <table width="300px" cellpadding="0px" cellspacing="0px" border="0">
            <tr>
              <td colspan="2">
                <div class="titleBar">
                  <xsl:value-of select="@address"/>
                </div>
              </td>
            </tr>
            <xsl:for-each select="sms">
              <xsl:choose>
                <xsl:when test="@type='3'">
                  <!-- BEGIN Sent Message -->
                  <tr align="right">
                    <td>
                      <table border="0">
                        <tr align="right">
                          <td width="20%"></td>
                          <td width="80%">
                            <div class="SMSDate">
                              <xsl:value-of select="@timeStamp"/>
                            </div>
                            <table cellpadding="0px" cellspacing="0px" border="0">
                              <tr height="13px">
                                <td class="oTopLeft"></td>
                                <td class="oTopMiddle"></td>
                                <td class="oTopRight"></td>
                              </tr>
                              <tr>
                                <td class="oMiddleLeft"></td>
                                <td class="oCenter">
                                  <xsl:value-of select="."/>
                                </td>
                                <td class="oMiddleRight"></td>
                              </tr>
                              <tr height="15px">
                                <td class="oBottomLeft"></td>
                                <td class="oBottomMiddle"></td>
                                <td class="oBottomRight"></td>
                              </tr>
                            </table>
                          </td>
                        </tr>
                      </table>
                    </td>
                  </tr>
                  <!-- END Sent Message -->
                </xsl:when>
                <xsl:otherwise>
                  <!-- BEGIN Received Message -->
                  <tr>
                    <td>
                      <table>
                        <tr>
                          <td width="80%">
                            <div class="SMSDate">
                              <xsl:value-of select="@timeStamp"/>
                            </div>
                            <table cellpadding="0px" cellspacing="0px" border="0">
                              <tr height="13px">
                                <td class="iTopLeft"></td>
                                <td class="iTopMiddle"></td>
                                <td class="iTopRight"></td>
                              </tr>
                              <tr>
                                <td class="iMiddleLeft"></td>
                                <td class="iCenter">
                                  <xsl:value-of select="."/>
                                </td>
                                <td class="iMiddleRight"></td>
                              </tr>
                              <tr height="12px">
                                <td class="iBottomLeft"></td>
                                <td class="iBottomMiddle"></td>
                                <td class="iBottomRight"></td>
                              </tr>
                            </table>
                          </td>
                          <td width="20%"></td>
                        </tr>
                      </table>
                    </td>
                  </tr>
                  <!-- END Received Message -->
                </xsl:otherwise>
              </xsl:choose>
            </xsl:for-each>
          </table>
        </div>
		<br/><br/>
        <span style="font-size:8px;">
          Generated with: 
          <a href="http://code.google.com/p/ndara/" target="_blank"> Ndara iSMS Backup</a>
        </span>
      </body>
    </html>
    </xsl:template>
  </xsl:stylesheet>
  